home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13139 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  57 lines

  1. Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
  2. From: grantp@usa.pipeline.com(Pete Grant)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Newbie Ques: Templates and C++
  5. Date: 23 Mar 1996 22:06:18 GMT
  6. Organization: Pipeline USA
  7. Message-ID: <4j1skq$bdt@news1.h1.usa.pipeline.com>
  8. References: <DoqLy6.H7q@novice.uwaterloo.ca>
  9. NNTP-Posting-Host: 38.8.60.5
  10. X-PipeUser: grantp
  11. X-PipeHub: usa.pipeline.com
  12. X-PipeGCOS: (Pete Grant)
  13. X-Newsreader: Pipeline v3.5.0
  14.  
  15. On Mar 23, 1996 20:22:54 in article <Newbie Ques: Templates and C++>,
  16. 'a2patel@novice.uwaterloo.ca (Aashish-Kaski-Ashman-Patel)' wrote: 
  17.  
  18.  
  19. >Ok.. Here is what I am trying to do: 
  20. >1)  
  21. >Have a class called Dictionary that depends on two other classes (
  22. determined 
  23. >at compile time ). 
  24. >ie. #ifdef HASH 
  25. >class Dictionary Hash-Table; 
  26. >#else-if BST 
  27. >class Dictionary Bst; 
  28. >#endif 
  29. Oops, I was concentrating on answering your questions and missed it.  The
  30. class 
  31. declarations above are incorrect.  Maybe you want: 
  32.  
  33. class Dictionary : public HashTable<int> { ...}; 
  34.  
  35. or 
  36.  
  37. template<class T> 
  38. class Dictionary : public HashTable<T> { .. }; 
  39.  
  40. or 
  41.  
  42. class Dictionary 
  43.  { 
  44.    private: 
  45.      HashTable<int> table; 
  46.  
  47. or .. whatever you want to do.  It's not obvious from your post. 
  48.  
  49.  
  50.  
  51. -- 
  52.  
  53. Pete Grant 
  54. Kalevi, Inc. 
  55. Sofware Engineering
  56.